package spring.yongongsystem.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import spring.yongongsystem.POJO.dto.WorkerPageQueryDTO;
import spring.yongongsystem.POJO.entity.Worker;

@Mapper
public interface WorkerMapper{
    
    
    
    @Select("select * from worker where username = #{username}")
    Worker getByUsername(String username);

    /**
     * 用工分页查询
     *
     * @param workerPageQueryDTO
     * @return
     */
    Page<Worker> pageQuery(WorkerPageQueryDTO workerPageQueryDTO);
    
    void update(Worker worker);

    @Insert("insert into worker(username, password, phone, name)" +
            " VALUES" +
            " (#{username},#{password},#{phone},#{name})")
    void insert(Worker worker);
    @Delete("delete from worker where id = #{id}")
    void deleteById(Long id);

    @Select("SELECT * FROM worker WHERE id = #{id}")
    Worker getById(Long id);

    @Select("SELECT COUNT(*) FROM worker;")
    long count();
}